# class Dish:
#     def __init__(self, name, price, number):  # 实例属性：菜品名称、价格、库存数量。
#         self.name = name
#         self.price = price
#         self.number = number
#
#     def show_dish(self):  # 展示菜品信息
#         print(f"菜品名称:{self.name},价格:{self.price},库存数量:{self.number}")
#
# class Customer:
#     def __init__(self, name):  # 实例属性：顾客姓名、订单（字典：菜品 -> 数量）
#         self.name = name
#         self.orders = {}
#
#     def show_order(self):  # 展示顾客订单信息
#         if self.orders:
#             for dish, quantity in self.orders.items():  # 菜品 -> 数量
#                 print(f"菜品名称{dish.name} × 数量{quantity} 价格：{dish.price}, 总价: {dish.price * quantity}")
#         else:
#             print("没有订单")
#
# class OrderManager:
#     def __init__(self):
#         self.dishes = {}  # 菜品列表
#         self.all_orders = {}  # 所有订单记录
#
#     def add_dish(self, dish):  # 添加菜品
#         if dish not in self.dishes.values():
#             self.dishes[dish.name] = dish
#             print(f"菜品{dish.name}成功添加")
#         else:
#             print(f"菜品{dish.name}已存在")
#
#     def remove_dish(self, dish):  # 删除菜品
#         if dish in self.dishes.values():
#             self.dishes.pop(dish.name)
#             print(f"菜品{dish.name}成功删除")
#         else:
#             print(f"菜品{dish.name}不存在")
#
#     def show_dishes(self):  # 查看所有菜品
#         if self.dishes:
#             for d in self.dishes.values():
#                 print(d.name)
#         else:
#             print("菜品为空")
#
#     def get_order(self, customer, dish, num):
#         if dish.name in self.dishes:  # 在菜品列表中
#             if dish.number >= num:  #
#                 dish.number -= num
#                 customer.orders[dish] = num
#                 print(f"{customer.name}的订单: {dish.name}*{num}")
#                 self.all_orders[customer.name] = customer
#             else:
#                 print(f"库存不足")
#         else:
#             print(f"菜品不存在")
#             print(f"{customer.name}的订单: {dish.name}*{num}")
#
#     def calculate(self, customer):  # 计算订单总金额
#         money = 0
#         for dish, num in customer.orders.items():
#             money += dish.price * num
#             print(f"顾客{customer.name}的订单总金额：{money}")
#
#     def show_orders(self):  # 展示所有订单。
#         for customer, order in self.all_orders.items():
#             print(f"顾客{customer}的订单是")
#             for dish, num in order.orders.items():
#                 print(f"菜品：{dish.name}×数量：{num}")
#
# # 创建菜品
# d1 = Dish("a", 2, 10)
# d2 = Dish("b", 3, 15)
# d3 = Dish("c", 4, 20)
# # 创建订单管理类
# m = OrderManager()
# # 添加菜品
# m.add_dish(d1)
# m.add_dish(d2)
# m.add_dish(d3)
# # 查看菜品
# m.show_dishes()
# # 创建顾客
# c1 = Customer("A")
# c2 = Customer("B")
# # 顾客下单
# m.get_order(c1, d1, 5)
# m.get_order(c1, d2, 5)
# m.get_order(c2, d3, 5)
# # 查看顾客订单信息
# c1.show_order()
# c2.show_order()
# # # 计算订单总金额
# m.calculate(c1)
# m.calculate(c2)
# # 展示所有订单
# m.show_orders()